import {fetch_get, fetch_post} from '../_utils/request'
import { baseUrl } from '../../config/index'

// 获取文章全部信息
export async function queryArticleAll(data){
  return fetch_post({
    url:baseUrl+"article/list",
    method:"POST",
    data:{
      pageSize:data.pageSize,
      pageNum:data.pageNum,
      title:data.title,
      type:data.type
    }
  })
}


// 获取文章全部信息
export async function queryArticleItemAll(data){
  return fetch_post({
    url:baseUrl+"article/item/list",
    method:"POST",
    data:{
      pageSize:10,
      pageNum:1,
      pid:data.pid
    }
  })
}

// 新增文章合集
export async function addArticle(data){
  return fetch_post({
    url:baseUrl+"article/add",
    method:"POST",
    data:data
  })
}


// 新增文章合集
export async function addArticleItem(data){
  return fetch_post({
    url:baseUrl+"article/item/add",
    method:"POST",
    data:data
  })
}


// 修改文章合集
export async function updateArticle(data){
  return fetch_post({
    url:baseUrl+"article/update",
    method:"PUT",
    data:data
  })
}



// 修改文章合集
export async function updateArticleItem(data){
  return fetch_post({
    url:baseUrl+"article/item/update",
    method:"PUT",
    data:data
  })
}


// 修改文章合集
export async function deleteArticle(data){
  return fetch_post({
    url:baseUrl+"article/delete",
    method:"DELETE",
    data:data
  })
}


// 删除
export async function deleteArticleItem(data){
  return fetch_post({
    url:baseUrl+"article/item/delete",
    method:"DELETE",
    data:data
  })
}





export async function getUserInfo(){
  return fetch_get({
    url:baseUrl+"user"
  })
}

// 修改用户信息
export async function updateUser(data){
  console.log(data);
  return fetch_post({
    url:baseUrl+"user",
    method:"PUT",
    data:{
      username:data.nickName,
      phone:data.phoneNumber,
      sex:data.gender,
      avatar:data.avatarUrl
    }
  })
}


